package com.blog.service.impl;

import com.blog.entity.Section;
import com.blog.repository.SectionReposity;
import com.blog.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SectionServiceImpl implements SectionService {

  @Autowired
  private SectionReposity sectionReposity;

  @Override
  public List<Section> getAllSections() {
    return sectionReposity.findAll();
  }

  @Override
  public void updateSection(Section section) {
    sectionReposity.save(section);
  }

  @Override
  public void saveSection(Section section) {
    sectionReposity.save(section);
  }

  @Override
  public boolean deleteSection(Long id) {
    if (sectionReposity.existsById(id)) {
      sectionReposity.deleteById(id);
      return true;
    }
    return false;
  }
}